// ws_party_const/pages/home/home.js
const app = getApp();
const {
  $util,
} = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getNavList();
  },

  getNavList() {
    $util.request({
      url: 'entry/wxapp/base.def.getthridapp',
      showLoading: false,
      success: (res) => {
        this.setData({
          apps: res.apps,
        });
      },
    });
  },
  getQueryVariable(url) {
    if (url.indexOf('?') !== -1) {
      // url 中存在参数
      let paraUrl = url.split('?');
      let paraArr = paraUrl[1].split('&');
      let paraObj = {};
      for (let i = 0; i < paraArr.length; i++) {
        let para = paraArr[i].split('=');
        let key = para[0];
        if (key) {
          paraObj = Object.assign(paraObj, {
            [key]: para[1],
          });
        }
      }
      return paraObj;
    } else {
      return {};
    }
  },

  commonJump(e) {
    let url = e.currentTarget.dataset.item.path;
    app.util.navigateTo(url.split('?')[0], this.getQueryVariable(url)); 
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
});